package com.cmwa.solution.sys.permission.dataAuthority.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cmwa.solution.base.entity.Page;
import com.cmwa.solution.base.entity.SearchParam;
import com.cmwa.solution.sys.permission.dataAuthority.dao.DataAuthorityDao;
import com.cmwa.solution.sys.permission.dataAuthority.entity.RoleVo;
import com.cmwa.solution.sys.permission.dataAuthority.service.DataAuthorityService;

@Service
public class DataAuthorityServiceImpl implements DataAuthorityService {
	
	@Resource
	private DataAuthorityDao dataAuthorityDao;
	
	public Page<RoleVo> dataAuthorityListPage(SearchParam sp) {
		String roleType = (String) sp.getSp().get("roleType");
		if("1".equals(roleType)){
			List<RoleVo> items =dataAuthorityDao.dataAuthorityListPageForTypeTwo(sp);
			return Page.create(items, sp.getStart(), sp.getLimit(), sp.getTotal());	
		}else {
			List<RoleVo> items =dataAuthorityDao.dataAuthorityListPageForNullSparam(sp);
			return Page.create(items, sp.getStart(), sp.getLimit(), sp.getTotal());
		}
	}
	
}